package com.catal.framework.data;



/**
 * 查询条件类
 * @author chensr
 *
 */
public class Condition_bak2 {
	/**
	 * 条件表达式左边项
	 */
	private String leftItem;
	
	/**
	 * 条件表达式
	 */
	private String operType;
	
	/**
	 * 条件表达式右边值
	 */
	private String value1;
	
	/**
	 * 条件表达式右边值2
	 */
	private String value2;
	
	public Condition_bak2() {
		super();
	}
	
	/**
	 * 无值构造方法  is null、is not null
	 * @param leftItem 左边表达式（列）
	 * @param operType 操作方式(操作符)
	 */
	public Condition_bak2(String leftItem, String operType) {
		super();
		this.leftItem = leftItem;
		this.operType = operType;
	}

	/**
	 * 单值值构造方法  =、 >、 <、 <=、>=、 like 
	 * @param leftItem 左边表达式（列）
	 * @param operType 操作方式(操作符)
	 * @param value1	值一
	 */
	public Condition_bak2(String leftItem, String operType, String value1) {
		super();
		this.leftItem = leftItem;
		this.operType = operType;
		this.value1 = value1;
	}

	/**
	 * 双值构造方法
	 * @param leftItem 左边表达式（列）
	 * @param operType 操作方式(操作符)
	 * @param value1	值一
	 * @param value2	值二
	 */
	public Condition_bak2(String leftItem, String operType, String value1,
			String value2) {
		super();
		this.leftItem = leftItem;
		this.operType = operType;
		this.value1 = value1;
		this.value2 = value2;
	}
	
	/**
	 * 子类中添加右边的条件
	 * @param condition
	 */
	public void addRightItem(Condition_bak2 condition){
		
	}
	/**
	 * 子类中添加左边条件下
	 * @param condition
	 */
	public void setLeftCondition(Condition_bak2 condition){
		
	}
	
	public String toString(){
		String str = getLeftItem()+ " ";
		if(ConditionOperSign.EQUAL.equals(operType)){
			str += "=";
			if(value1 instanceof String){
				str+="'"+value1+"'";
			}else{
				str += value1;
			}
		}else if(ConditionOperSign.LIKE.equals(operType)){
			str += " like ";
			str +="'%"+value1+"%'";
		}else if(ConditionOperSign.LT.equals(operType)){
			str += "<";
			if(value1 instanceof String){
				str+="'"+value1+"'";
			}else{
				str += value1;
			}
		}else if(ConditionOperSign.GT.equals(operType)){
			str += ">";
			if(value1 instanceof String){
				str+="'"+value1+"'";
			}else{
				str += value1;
			}
		}else if(ConditionOperSign.LE.equals(operType)){
			str += "<=";
			if(value1 instanceof String){
				str+="'"+value1+"'";
			}else{
				str += value1;
			}
		}else if(ConditionOperSign.GE.equals(operType)){
			str += ">=";
			if(value1 instanceof String){
				str+="'"+value1+"'";
			}else{
				str += value1;
			}
		}else if(ConditionOperSign.BETWEEN.equals(operType)){
			if(value1 instanceof String){
				str+= "BETWEEN '" + value1 + "' AND '" + value2 + "'";
			}else{
				str+= "BETWEEN " + value1 + " AND " + value2;
			}
		}else if(ConditionOperSign.IS_NULL.equals(operType)){
			str += " is null";
		}else if(ConditionOperSign.IS_NOT_NULL.equals(operType)){
			str += " IS NOT NULL ";
		}
		return str;
	}
	public String getLeftItem() {
		return leftItem;
	}
	public void setLeftItem(String leftItem) {
		this.leftItem = leftItem;
	}
	public String getOperType() {
		return operType;
	}
	public void setOperType(String operType) {
		this.operType = operType;
	}
	public String getValue1() {
		return value1;
	}
	public void setValue1(String value1) {
		this.value1 = value1;
	}
	public String getValue2() {
		return value2;
	}
	public void setValue2(String value2) {
		this.value2 = value2;
	}
}
